﻿@using RuoVea.ExEnum
@using RuoVea.ExSugar.Entity;
@using RuoVea.OmiApi.Article.Service
@using RuoVea.OmiApi.Article.Service.Dto
@inject ArticleService _articleService;
@{
    Layout = "_Layout";
    // 从URL中提取ID
    var currentPath = Context.Request.Path.Value;
    long? currentArticleId = null;

    if (currentPath.StartsWith("/Details/") && currentPath.EndsWith(".html"))
    {
        var idString = currentPath.Replace("/Details/", "").Replace(".html", "");
        if (long.TryParse(idString, out var id))
            currentArticleId = id;
    }
    var article = await _articleService.GetDataAsync(new EntityBaseId { Id = currentArticleId ?? 0 }) ?? new ArtArticleOutDto();
    await _articleService.PlusViewCountAsync(new EntityBaseId { Id = currentArticleId ?? 0 });
    var articleList = await _articleService.GetPagesAsync(new ArticleParam { CategorieIsDisable = YesOrNot.N,  TagIds = article.TagIds , PageNo = 1, PageSize = 3 });
}

<div class="cl-artical-content">
    <h2 class="cl-artical-title">@Html.Raw(article.Title)</h2>
    <div class="cl-card-tag">
        <div><span>@article.ViewCount</span>人浏览 / <span>@article.LikeCount</span>人喜欢</div>
    </div>
    <div class="cl-artical">
        @Html.Raw(article.Content)
    </div>
</div>
@if (articleList != null && articleList.Rows?.Count() > 0)
{
    <div class="recommend-panel">
        <h4 class="right-card-title">相关文章</h4>
        <div class="card-deck">
            @foreach (var c in articleList.Rows)
            {
                <div class="card ll-panel">
                    <a class="recommend-panel-link" href="@("/Details/"+@c.Id+".html")">
                    <div class="recommend-panel-top">
                        <img src="@c.CoverImage" class="img-fluid" alt="@Html.Raw(c.Title)">
                    </div>
                    <div class="recommend-panel-bottom">
                        @Html.Raw(c.Title)
                    </div>
                </a>
            </div>
            } 
        </div>
    </div>
}
@* <div class="comment">
    <form class="cl-comment-from">
        <div><textarea placeholder="说点什么吧..." rows="1"></textarea></div>
        <button type="button">留言</button>
        <span class="clearfix"></span>
    </form>


    <h4 class="right-card-title">全部评论</h4>
    <div class="comment-panel">
        <div class="comment-panel-portrait">
            <img src="img/portrait.png" class="img-fluid rounded-circle" alt="">
        </div>
        <div class="comment-panel-content">
            <div class="comment-panel-content-item">
                <div class="comment-author">晴天下起了小雨</div>
                <div>2017-10-01 18:00</div>
            </div>
            <div class="comment-panel-content-main">很喜欢，果断关注了</div>
        </div>
        <span class="clearfix"></span>
        <div class="text-primary"><a href="">回复</a></div>
    </div>

    <div class="comment-panel">
        <div class="comment-panel-portrait">
            <img src="img/portrait.png" class="img-fluid rounded-circle" alt="">
        </div>
        <div class="comment-panel-content">
            <div class="comment-panel-content-item">
                <div class="comment-author">wjmyly7336064</div>
                <div>2017-10-01 18:00</div>
            </div>
            <div class="comment-panel-content-main">相当实用，赞美了</div>
            <!--comment-secondary-panel-->
            <div class="comment-secondary-panel">
                <span class="triangle-icon"><i class="fa fa-sort-asc" aria-hidden="true"></i></span>
                <div class="comment-panel-content">
                    <div class="comment-panel-content-item">
                        <div class="comment-author">橘大佬</div>
                        <div>2017-10-01 18:00</div>
                    </div>
                    <div class="comment-panel-content-main">就是有些细节再到位点就好了…</div>
                </div>
                <span class="clearfix"></span>
            </div>
            <!---->
        </div>
        <span class="clearfix"></span>
        <div class="text-primary"><a href="">回复</a></div>
    </div>

</div> *@
